
from abc import ABC, abstractmethod
class IFile(ABC):
    def write_str(self, s: str):
        print("write_str:")
        self.write_bytes(s.encode("UTF-8"))

    @abstractmethod
    def write_bytes(self, bs: bytes):
        pass

class IDevice(ABC):
    def write_block(self, s: str):
        print("write_block:")
        self.write_block_bytes(s.encode("UTF-8"))

    @abstractmethod
    def write_block_bytes(self, bs: bytes):
        pass

class Device(IFile, IDevice):
    def __init__(self, name: str):
        self.__name = name

    def write_bytes(self, s: bytes):
        print(f"write_str for name:{self.__name},s:{s}")
    def write_block_bytes(self, s: bytes):
        print(f"write_block for name:{self.__name}, s:{s}")


import unittest 
class TestIf(unittest.TestCase):
    def test_main(self):
        d = Device("dev1")
        f: IFile = d
        f.write_str("str")

        dev: IDevice = d
        dev.write_block("block")
